<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
	.calcel{
		color: #7f8c8d;
		text-decoration:line-through;
	}
</style>
<%@include file="/WEB-INF/jsp/public/commons.jspf"%>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/base.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/reset.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/post.css" />
<script type="text/javascript" src="${pageContext.request.contextPath }/script/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/script/base.js"></script>
<script src="${pageContext.request.contextPath }/ckeditor/ckeditor.js"></script>

</head>
<body>
<div class="container">
<ol class="breadcrumb">
  <li><a href="home_outerCentre.action">首页</a></li>
  <li><a href="forum_prelist.action">论坛</a></li>
  <li><a href="topic_list.action?id=${topic.forum.id}">${topic.forum.name}</a></li>
  <li class="active">主题贴</li>
</ol>
</div>
<!--内容区域	start-->
	<div id="bmain">

		<!--管理员菜单	start-->
				<!--管理员菜单	end-->
				<!--帖子内容	start-->
		<div class="bw1100 clearfix bmt10">
			<div class="b_adimg">
				<script>write_ad("bbs_1floor_right");CNMO_AD.init();</script>
			</div>
			<!--左栏	start-->
			<div class="bcontleft fl" id="post_list">
				<div class="bpostcont">
					<!--标题	start-->
					<div class="b_title">
						<p>
							<s:if test="#topic.type==3">
								<a>[置顶]</a>
							</s:if>
							<s:if test="#topic.type==2">
								<a>[精华]</a>
							</s:if>
							<span>${topic.title }</span>
						</p>
						
						
						<div class="b_detail">
							<span>${topic.postTime }</span>
							<!-- <span><em class="b_browse b_picon"></em>104</span> -->
							<span class="b_replies" id="b_replies">
								<em class="b_repicon b_picon"></em>评论(<em>${topic.replyCount }</em>)
							</span>
							<span style="padding-left: 50px;">
								<s:a action="topic_cream?id=%{id}&pageNum=%{pageNum}">精华 |</s:a>
								<s:a action="topic_top?id=%{id}&pageNum=%{pageNum}">置顶 |</s:a> 
								<s:a action="topic_del?id=%{id}">删除</s:a>
							</span>
						</div>
					</div>
					<!--标题	end-->
					<!--内容	start-->
					<div class="b_cont">
							<!--帖子内容-->
						<div class="b_article" id="b_article">
										<p>${topic.content }<p>		
						</div>
					</div>
					<!--内容	end-->
					
				  </div>
					<!--最新评论	start-->
				<div class="bnewcom bmt10" id="bnewcom">
					<div class="bncom_title clearfix">
						<div class="fl">
							最新评论<em class="bn_num">（${topic.replyCount }）</em>
							<a id="go_comment" name="go_comment"></a>
						</div>
					</div>
					<!--评论楼层	start-->
					<s:iterator value="recordList" status="status">
						<div class="bcom_floor clearfix">
							<div class="bcom_headpic fl">
								<a href="${pageContext.request.contextPath }/personal_center.action?id=${author.id}">
									<img src="${pageContext.request.contextPath }${author.photo }" />
								</a>
							</div>
							<div class="bcom_cont fl">
								<div class="bcom_detail">
									<span>
										<a href="${pageContext.request.contextPath }/personal_center.action?id=${author.id}">${author.name }</a>
										<!-- <em class="blevel">LV.4</em> -->									<!--新加管理员、版主、超级版主-->
																											</span>
									<span>发表于：${postTime }</span>
									<span>
										<em class="fl">来自：</em><a id="floor_2" name="floor_2" href="javascript:void(0);" rel="nofollow">PC端</a>								
									</span>
									<!--沙发 板凳 楼梯-->
									<em class="bc_firstf fr">#${(pageNum-1)*10+status.count } <s:a action="reply_del?id=%{id}&topicId=%{topic.id}&pageNum=%{pageNum}">撤销</s:a></em>
								</div>
								<div class="bcom_text">${content } </div>
		
								
							</div>
						</div>
					</s:iterator>
					

					<!--评论楼层	end-->
				</div>
				<!--最新评论	end-->
								
				<!--底部翻页	start-->
				<div class="clearfix bmt10">
					<div class="bpageslist fr">
						<div class="List-pages fr">
							<span>
								<a href="${pageContext.request.contextPath }/topic_list.action?id=${topic.forum.id}">
									<em class="golist_icon"></em>返回列表
								</a>
							</span>
							<c:if test="${currentPage!=1}">
								<a href="javascript:gotoPage(1)">首页</a>
							</c:if>
							<c:if test="${currentPage==1}">
								<span>首页</span>
							</c:if>
							<c:if test="${currentPage>1}">
								<a href="javascript:gotoPage(${currentPage-1})">&lt;上一页</a>
							</c:if>
							<c:if test="${currentPage<=1}">
								<span>&lt;上一页</span>
							</c:if>
							<c:forEach begin="${beginPageIndex}" end="${endPageIndex}" var="num">
								<c:if test="${num==currentPage}">
									<span class="cur">${num}</span>
								</c:if>
								<c:if test="${num!=currentPage}">
									<a href="javascript:gotoPage(${num})" target="_self">${num}</a>
								</c:if>
							</c:forEach>
							<c:if test="${currentPage<pageCount}">
								<a href="javascript:gotoPage(${currentPage+1})">下一页&gt;</a>
							</c:if>
							<c:if test="${currentPage>=pageCount}">
								<span>下一页&gt;</span>
							</c:if>
							<c:if test="${currentPage!=pageCount}">
								<a href="javascript:gotoPage(${pageCount})">尾页</a>
							</c:if>
							<c:if test="${currentPage==pageCount}">
								<span>尾页</span>
							</c:if>
							<span class="bornone">
								跳到<input class="go_pages" type="text" value="" onkeyup="gotoPage(this.value)" onkeydown="gotoPage(this.value)" id="page_num"/>页
							</span>
						</div>
					</div>
				</div>
				<!--底部翻页	end-->
								
				<!--高级模式 start-->
				<div class="b_advpub bmt10">
					<div class="b_aheadpic fl">
						<s:if test="#session.user==null">
							<img src="${pageContext.request.contextPath }/images/person.jpg"/>
						</s:if>
						<s:if test="#session.user.photo==''">
						    <a href="${pageContext.request.contextPath }/personal_center.action?id=${user.id }">
						      <img src="${pageContext.request.contextPath }/images/person.jpg"/>
						    </a>
						</s:if>
						<s:if test="#session.user.photo!=''">
							<a href="${pageContext.request.contextPath }/personal_center.action?id=${user.id }">
						     <img src="${pageContext.request.contextPath }${user.photo}"/>
							</a>
						</s:if>
						<p>
							<s:if test="#session.user==null">
							  	游客
							</s:if>
							<s:if test="#session.user!=null">
								<a href="${pageContext.request.contextPath }/personal_center.action?id=${user.id }">${user.name }</a>
							</s:if>
						</p>
						</div>
					<div class="b_areplys fl" style="margin-left:50px;">
					  <s:if test="#session.user==null">
					    <div class="b_loghint">
							<p>
								您需要注册登录后，才能回帖哦！
								<span>
									<a href="${pageContext.request.contextPath }/user_login.action">登录</a>
									<em>|</em>
									<a href="${pageContext.request.contextPath }/user_registUI.action">注册</a>
								</span>
							</p>
						</div>
					  </s:if>
					  <s:if test="#session.user!=null">
						<div class="b_eaitor filcon">
							<textarea id="content" name="content" rows="10" cols="150">
	                
	            			</textarea>
							<div class="b_publish">
								<input class="fr" type="button" id="submit" value="发表" />
							</div>
						</div>
					  </s:if>
					</div>
				</div>
				<!--高级模式	end-->
			</div>
			<!--左栏	end-->
			<!--右栏	start-->
			<div class="bcontright fl" id="bcontright">
				<div class="br_authorinfor">
				<!--楼主信息-->
					<div class="br_author" style="width:300px;">
						<div class="br_owner b_picon"></div>
						<div class="br_autpic">
							<a href="${pageContext.request.contextPath }/personal_center.action?id=${topic.author.id }">
								<img src="${pageContext.request.contextPath }${topic.author.photo }">
							</a>
						</div>
						<div class="br_autname">
							<p class="autname">
								<span><a href="${pageContext.request.contextPath }/personal_center.action?id=${topic.author.id }">${topic.author.name }</a></span><!-- <em class="blevel">LV.1</em> -->
							</p>
							<!--管理员图标adminic/超级版主图标vipbanzhuic/版主图标banzhuic-->
					 </div>
						<div class="br_num">
							<div class="fl" style="margin-top:-13px;">
								
									<p>${topicCount }</p>
									<p>帖子</p>
								
							</div>
							<div class="brline fl" style="margin-top:-13px;">
								
									<p>${topicCreamCount }</p>
									<p>精华</p>
								
							</div>
						</div>
						<!-- <p class="br_logtime">最近登录时间：2017-05-22</p> -->
					</div>
					<!--最近动态-->
					<div class="br_recen_news">
						<div class="br_divtitle">
							最近动态
						</div>
						<div class="br_r_newscont">
							<ul>
								<s:iterator value="#topics" var="t">
									<li>
										<i><span></span></i>
										<a href="${pageContext.request.contextPath }/topic_tiezi.action?id=${t.id}">${t.title }</a>
										<p>${t.postTime }</p>
									</li>	
								</s:iterator>				
							</ul>
						</div>
					</div>
				</div>
							
			</div>
			<!--右栏	end-->
		</div>
		<!--帖子内容	end-->
	</div>
	<!--内容区域	end-->
	
<script type="text/javascript">
	//分页
	function gotoPage( pageNum ){
		window.location.href="${pageContext.request.contextPath }/topic_tiezi.action?pageNum="+pageNum+"&id=${topic.id}";
	}
	
	CKEDITOR.replace( 'content',{
		height: '120px',
		width: '645px',
		customConfig: '${pageContext.request.contextPath }/script/replyConfig.js'//自定义配置文件
	});
	$(function(){
		$("#submit").click(function(){
			var content=CKEDITOR.instances.content.getData();
			if(content==""){
				ConfirmNotice.showBox({setContent: '请填写内容哦!'});
			}else{
				$.ajax({
		    		   type: "POST",
		    		   dataType:"json",
		    		   url: "${pageContext.request.contextPath }/reply_add.action",
		    		   data:{
			    			  "topicId":${topic.id},
			    			  "content":content 
			    		   },
		    		   success: function(data,textStatus){
		    			   if(textStatus=="success"){
		    				   document.location.reload();
		    			   }
		    		   }
		    	});
				//
			}
		});
	});
</script>
</body>
</html>